package com.zfk.transaction.util;

import com.zfk.transaction.entity.chat.ChatContent;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;

public class DateUtil {


    public static void sort(List<ChatContent> list){

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        if (list.size() > 1) {
            //list 集合正序排序
            list.sort((a1, a2) -> {
                try {

                    return sdf.parse(a1.getDate()).compareTo(sdf.parse(a2.getDate()));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                return 1;
            });
        }

    }

}
